﻿using System;
using System.Web.UI;
using System.ComponentModel;
using System.Web.UI.Design;

namespace TA.Turbo.Controls
{
	/// <summary>
	/// A panel, rendered either as a block (DIV) or inline (SPAN) element.
	/// </summary>
	[Designer(typeof(ContainerControlDesigner))]
	[ParseChildren(false)]
	[PersistChildren(true)]
	public class Panel : BaseSimpleControl
	{
		#region PUBLIC
		#region INIT
		/// <summary>
		/// Ctor.
		/// </summary>
		public Panel()
			: base(HtmlTextWriterTag.Div)
		{
		}
		#endregion
		#region PROPS
		/// <summary>
		/// Controls how this Panel is rendered.
		/// </summary>
		[DefaultValue(RenderMode.Block)]
		public RenderMode RenderMode { get; set; }
		[DefaultValue(HtmlTextWriterTag.Div)]
		public override HtmlTextWriterTag Tag
		{
			get
			{
				return base.Tag;
			}
			set
			{
				base.Tag = value;
			}
		}
		#endregion
		#endregion
		#region INTERNAL
		#region METHODS
		/// <summary>
		/// Renders the begin tag which is either a block (DIV) or an inline (SPAN) element.
		/// </summary>
		/// <param name="writer"></param>
		protected override void RenderBeginTag(HtmlTextWriter writer)
		{
			this.Tag = this.RenderMode == RenderMode.Block ? HtmlTextWriterTag.Div : HtmlTextWriterTag.Span;
			base.RenderBeginTag(writer);
		}
		#endregion
		#endregion
	}
}

